home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 2.iso / dist / fw_gsl.idb / usr / freeware / info / gsl-ref.info-1.z / gsl-ref.info-1
Text File  |  2000-10-09  |  50KB  |  1,312 lines

  1. This is gsl-ref.info, produced by Makeinfo version 3.12h from
  2. gsl-ref.texi.
  3.  
  4. INFO-DIR-SECTION Scientific software
  5. START-INFO-DIR-ENTRY
  6. * gsl-ref: (gsl-ref).                   GNU Scientific Library - Reference
  7. END-INFO-DIR-ENTRY
  8.  
  9.    This file documents the GNU Scientific Library.
  10.  
  11.    Copyright (C) 1996, 1997, 1998, 1999 The GSL Project.
  12.  
  13.    Permission is granted to make and distribute verbatim copies of this
  14. manual provided the copyright notice and this permission notice are
  15. preserved on all copies.
  16.  
  17.    Permission is granted to copy and distribute modified versions of
  18. this manual under the conditions for verbatim copying, provided that
  19. the entire resulting derived work is distributed under the terms of a
  20. permission notice identical to this one.
  21.  
  22.    Permission is granted to copy and distribute translations of this
  23. manual into another language, under the above conditions for modified
  24. versions, except that this permission notice may be stated in a
  25. translation approved by the Foundation.
  26.  
  27. 
  28. File: gsl-ref.info,  Node: Top,  Next: Preliminaries,  Prev: (dir),  Up: (dir)
  29.  
  30. GSL
  31. ***
  32.  
  33.    This file documents the GNU Scientific Library, a collection of
  34. numerical routines for scientific computing.
  35.  
  36.    As of 19 May 2000 the library is in developers release only and is
  37. not recommended for general use.
  38.  
  39. * Menu:
  40.  
  41. * Preliminaries::
  42. * Using the library::
  43. * Error handling in GSL::
  44. * Mathematical Functions::
  45. * Complex Numbers::
  46. * Vectors and Matrices::
  47. * BLAS Support::
  48. * Linear Algebra::
  49. * Eigensystems::
  50. * Special Functions::
  51. * Roots of Polynomials::
  52. * Interpolation::
  53. * Series Acceleration::
  54. * Random Number Generation::
  55. * Random Number Distributions::
  56. * Permutations::
  57. * Sorting::
  58. * Statistics::
  59. * Histograms::
  60. * One dimensional Root-Finding::
  61. * Multidimensional Root-Finding::
  62. * Minimization::
  63. * Simulated Annealing::
  64. * Fast Fourier Transforms::
  65. * Discrete Hankel Transforms::
  66. * Numerical Integration::
  67. * Monte Carlo Integration::
  68. * Ordinary Differential Equations (ODEs)::
  69. * IEEE floating-point arithmetic::
  70. * Debugging Numerical Programs::
  71. * Contributors to GSL::
  72. * Copying::
  73. * Concept Index::
  74. * Function Index::
  75. * Variable Index::
  76. * Type Index::
  77.  
  78. 
  79. File: gsl-ref.info,  Node: Preliminaries,  Next: Using the library,  Prev: Top,  Up: Top
  80.  
  81. Preliminaries
  82. *************
  83.  
  84.    The GNU Scientific Library (GSL) is a collection of routines for
  85. numerical computing.  The routines are written from scratch by the GSL
  86. team (*note Contributors to GSL::.) in C, and are meant to present a
  87. modern Applications Programming Interface (API) for C programmers, while
  88. allowing wrappers to be written for very high level languages.
  89.  
  90.    GSL is currently in developers release, for people who want to work
  91. on the library itself. When the library is complete and fully tested it
  92. will be announced for general use.
  93.  
  94. 
  95. File: gsl-ref.info,  Node: Using the library,  Next: Error handling in GSL,  Prev: Preliminaries,  Up: Top
  96.  
  97. Using the library
  98. *****************
  99.  
  100.    This chapter describes how to compile programs that use GSL, and
  101. introduces its conventions.
  102.  
  103. * Menu:
  104.  
  105. * ANSI C Compliance::
  106. * Compiling and Linking::
  107. * Automake macros::
  108. * Shared Libraries::
  109. * Inline functions::
  110. * Long double::
  111. * Alternative optimized functions::
  112. * Support for different numeric types::
  113. * Compatibility with C++::
  114. * Aliasing of arrays::
  115.  
  116. 
  117. File: gsl-ref.info,  Node: ANSI C Compliance,  Next: Compiling and Linking,  Up: Using the library
  118.  
  119. ANSI C Compliance
  120. =================
  121.  
  122.    The library is written in ANSI C and is intended to conform to the
  123. ANSI C standard.  It should be portable to any system with a working
  124. ANSI C compiler.
  125.  
  126.    The library does not rely on any non-ANSI extensions in the
  127. interface it exports to the user.  Programs you write using GSL can be
  128. ANSI compliant.  Extensions which can be used in a way compatible with
  129. pure ANSI C are supported, however, via conditional compilation.  This
  130. allows the library to take advantage of compiler extensions on those
  131. platforms which support them.
  132.  
  133.    When an ANSI C feature is known to be broken on a particular system
  134. the library will exclude any related functions at compile-time.  This
  135. should make it impossible to link a program that would use these
  136. functions and give incorrect results.
  137.  
  138.    To avoid namespace conflicts all exported function names and
  139. variables have the prefix `gsl_', while exported macros have the prefix
  140. `GSL_'.
  141.  
  142. 
  143. File: gsl-ref.info,  Node: Compiling and Linking,  Next: Automake macros,  Prev: ANSI C Compliance,  Up: Using the library
  144.  
  145. Compiling and Linking
  146. =====================
  147.  
  148.    The library header files are installed in their own `gsl' directory.
  149. You should write any preprocessor include statements with a `gsl/'
  150. directory prefix thus,
  151.  
  152.      #include <gsl/gsl_math.h>
  153.  
  154. If the directory is not installed on the standard search path of your
  155. compiler you will also need to provide its location to the preprocessor
  156. as a command line flag.  The default location of the `gsl' directory is
  157. `/usr/local/include/gsl'.
  158.  
  159.    The library is installed as a single file, `libgsl.a'.  A shared
  160. version of the library is also installed on systems that support shared
  161. libraries.  The default location of these files is `/usr/local/lib'.
  162. To link against the library you need to specify both the main library
  163. and a supporting BLAS library.  A suitable blas implementation is
  164. provided in `libgslblasnative' if your system does not provide one.
  165. The following example shows how to link an application with the library,
  166.  
  167.      gcc app.o -lgsl -lgslblasnative -lm
  168.  
  169. The following command line shows how to link the same application with
  170. an alternative blas library `libmycblas',
  171.  
  172.      gcc app.o -lgsl -lgslblascblas -lmycblas -lm
  173.  
  174. The library must conform to the CBLAS standard.  For more information
  175. see *Note BLAS Support::.
  176.  
  177.    The program `gsl-config' provides information on the local version
  178. of the library.  For example, the following command shows that the
  179. library has been installed under the directory `/usr/local',
  180.  
  181.      bash$ gsl-config --prefix
  182.      /usr/local
  183.  
  184. Further information is available using the command `gsl-config --help'.
  185.  
  186. 
  187. File: gsl-ref.info,  Node: Shared Libraries,  Next: Inline functions,  Prev: Automake macros,  Up: Using the library
  188.  
  189. Shared Libraries
  190. ================
  191.  
  192.    To run a program linked with the shared version of the library it
  193. may be necessary to define the shell variable `LD_LIBRARY_PATH' to
  194. include the directory where the library is installed.  For example,
  195.  
  196.      LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH ./app
  197.  
  198. To compile a statically linked version of the program instead, use the
  199. `-static' flag in `gcc',
  200.  
  201.      gcc -static app.o -lgsl -lgslblasnative -lm
  202.  
  203. 
  204. File: gsl-ref.info,  Node: Automake macros,  Next: Shared Libraries,  Prev: Compiling and Linking,  Up: Using the library
  205.  
  206. Automake macros
  207. ===============
  208.  
  209.    The GSL library also provides some useful automake macros to use in
  210. your applications. The `gsl.m4' file contains the definitions needed to
  211. detect GSL in automatic Makefile generation.
  212.  
  213.    To use the macros simply add the following line to your
  214. `configure.in' file:
  215.  
  216.      AM_PATH_GSL(GSL_VERSION,AC_MSG_ERROR(Error message!))
  217.  
  218. where `GSL_VERSION' is the GSL Library version you need to compile and
  219. run your application, and where "Error message" is the warning you want
  220. to show if the required library is not found.
  221.  
  222.    Then, you can add the variables `GSL_LIBS' and `GSL_CFLAGS' to your
  223. Makefile.am files to obtain the correct compiler flags.  `GSL_LIBS' is
  224. equal to the output of the `gsl-config --libs' command and `GSL_CFLAGS'
  225. is equal to `gsl-config --cflags' command. For example,
  226.  
  227.      libgsdv_la_LDFLAGS =    \
  228.              $(GTK_LIBDIR) \
  229.              $(GTK_LIBS) -lgsdvgsl $(GSL_LIBS) -lgslblasnative
  230.  
  231. 
  232. File: gsl-ref.info,  Node: Inline functions,  Next: Long double,  Prev: Shared Libraries,  Up: Using the library
  233.  
  234. Inline functions
  235. ================
  236.  
  237. The `inline' keyword is not part of ANSI C and the library does not
  238. export any inline function definitions by default.  The inline versions
  239. of functions can be included by defining the macro `HAVE_INLINE' when
  240. compiling an application.
  241.  
  242.      gcc -c -DHAVE_INLINE app.c
  243.  
  244. If you use `autoconf' this macro can be defined automatically.  The
  245. following test should be placed in your `configure.in' file,
  246.  
  247.      AC_C_INLINE
  248.      
  249.      if test "$ac_cv_c_inline" != no ; then
  250.        AC_DEFINE(HAVE_INLINE,1)
  251.        AC_SUBST(HAVE_INLINE)
  252.      fi
  253.  
  254. and the macro will then be defined in the compilation flags or by
  255. including the file `config.h' before any library headers.  If you do
  256. not define the macro `HAVE_INLINE' then the slower non-inlined versions
  257. of the functions will be used instead.
  258.  
  259. 
  260. File: gsl-ref.info,  Node: Long double,  Next: Alternative optimized functions,  Prev: Inline functions,  Up: Using the library
  261.  
  262. Long double
  263. ===========
  264.  
  265.    The extended numerical type `long double' is part of the ANSI C
  266. standard and should be available in every modern compiler.  However, the
  267. precision of `long double' is platform dependent, and this should be
  268. considered when using it.  The IEEE standard only specifies the minimum
  269. precision of extended precision numbers, while `double' is the same on
  270. all platforms.
  271.  
  272.    In some system libraries the `stdio.h' formatted input/output
  273. functions `printf' and `scanf' are not implemented correctly for `long
  274. double'.  Undefined or incorrect results are avoided by testing these
  275. functions during the `configure' stage of library compilation and
  276. eliminating certain GSL functions which depend on them if necessary,
  277.  
  278.      checking whether printf/scanf works with long double... no
  279.  
  280. Consequently when `long double' formatted input/output does not work on
  281. a given system it will not be possible to link a program which uses GSL
  282. functions dependent on this.
  283.  
  284.    If it is necessary to work on a system which does not support
  285. formatted `long double' input/output then the options are to use binary
  286. formats or to convert `long double' results into `double' for reading
  287. and writing.
  288.  
  289. 
  290. File: gsl-ref.info,  Node: Alternative optimized functions,  Next: Support for different numeric types,  Prev: Long double,  Up: Using the library
  291.  
  292. Alternative optimized functions
  293. ===============================
  294.  
  295.    The main implementation of some functions in the library will not be
  296. optimal on all architectures.  For example, there are several ways to
  297. compute a Gaussian random variate and their relative speeds are
  298. platform-dependent.  In cases like this the library provides alternate
  299. implementations of these functions with the same interface.  If you
  300. write your application using calls to the standard implementation you
  301. can select an alternative version later via a preprocessor definition.
  302. It is also possible to introduce your own optimized functions this way
  303. while retaining portability.  For example,
  304.  
  305.      #ifdef SPARC
  306.      #define gsl_ran_gaussian gsl_ran_gaussian_ratio_method
  307.      #endif
  308.      #ifdef INTEL
  309.      #define gsl_ran_gaussian my_gaussian
  310.      #endif
  311.  
  312. Note that the alternative implementations will not produce bit-for-bit
  313. identical results, and in the case of random number distributions will
  314. produce an entirely different stream of random variates.
  315.  
  316. 
  317. File: gsl-ref.info,  Node: Support for different numeric types,  Next: Compatibility with C++,  Prev: Alternative optimized functions,  Up: Using the library
  318.  
  319. Support for different numeric types
  320. ===================================
  321.  
  322.    Many functions in the library are defined for different numeric
  323. types.  This feature is implemented by varying the name of the function
  324. with a type-related modifier -- a primitive form of C++ templates.  The
  325. modifier is inserted into the function name after the initial module
  326. prefix.  The following table shows the function names defined for all
  327. the numeric types of an imaginary module `gsl_foo' with function `fn',
  328.  
  329.      gsl_foo_fn               double
  330.      gsl_foo_long_double_fn   long double
  331.      gsl_foo_float_fn         float
  332.      gsl_foo_long_fn          long
  333.      gsl_foo_ulong_fn         unsigned long
  334.      gsl_foo_int_fn           int
  335.      gsl_foo_uint_fn          unsigned int
  336.      gsl_foo_short_fn         short
  337.      gsl_foo_ushort_fn        unsigned short
  338.      gsl_foo_char_fn          char
  339.      gsl_foo_uchar_fn         unsigned char
  340.  
  341. The normal numeric precision `double' is considered the default and
  342. does not require a suffix.  For example, the function `gsl_stats_mean'
  343. computes the mean of double precision numbers, while the function
  344. `gsl_stats_int_mean' computes the mean of integers.
  345.  
  346.    A corresponding scheme is used for library defined types, such as
  347. `gsl_vector' and `gsl_matrix'.  In this case the modifier is appended
  348. to the type name.  For example, if a module defines a new
  349. type-dependent struct or typedef `gsl_foo' it is modified for other
  350. types in the following way,
  351.  
  352.      gsl_foo                  double
  353.      gsl_foo_long_double      long double
  354.      gsl_foo_float            float
  355.      gsl_foo_long             long
  356.      gsl_foo_ulong            unsigned long
  357.      gsl_foo_int              int
  358.      gsl_foo_uint             unsigned int
  359.      gsl_foo_short            short
  360.      gsl_foo_ushort           unsigned short
  361.      gsl_foo_char             char
  362.      gsl_foo_uchar            unsigned char
  363.  
  364. When a module contains type-dependent definitions the library provides
  365. individual header files for each type.  The filenames are modified as
  366. shown in the below.  For convenience the default header includes the
  367. definitions for all the types.  To include only the double precision
  368. header, or any other specific type, file use its individual filename.
  369.  
  370.      #include <gsl/gsl_foo.h>                  All types listed below
  371.      #include <gsl/gsl_foo_double.h>           double
  372.      #include <gsl/gsl_foo_long_double.h>      long double
  373.      #include <gsl/gsl_foo_float.h>            float
  374.      #include <gsl/gsl_foo_long.h>             long
  375.      #include <gsl/gsl_foo_ulong.h>            unsigned long
  376.      #include <gsl/gsl_foo_int.h>              int
  377.      #include <gsl/gsl_foo_uint.h>             unsigned int
  378.      #include <gsl/gsl_foo_short.h>            short
  379.      #include <gsl/gsl_foo_ushort.h>           unsigned short
  380.      #include <gsl/gsl_foo_char.h>             char
  381.      #include <gsl/gsl_foo_uchar.h>            unsigned char
  382.  
  383. 
  384. File: gsl-ref.info,  Node: Compatibility with C++,  Next: Aliasing of arrays,  Prev: Support for different numeric types,  Up: Using the library
  385.  
  386. Compatibility with C++
  387. ======================
  388.  
  389.    The library header files automatically define functions to have
  390. `extern "C"' linkage when included in C++ programs.
  391.  
  392. 
  393. File: gsl-ref.info,  Node: Aliasing of arrays,  Prev: Compatibility with C++,  Up: Using the library
  394.  
  395. Aliasing of arrays
  396. ==================
  397.  
  398.    The library assumes that arrays, vectors and matrices passed as
  399. arguments are not aliased and do not overlap. This allows the library to
  400. use additional optimizations, and removes the need to handle overlapping
  401. memory regions as a special case.  If overlapping arguments are used
  402. then the results of such functions will be undefined.
  403.  
  404. 
  405. File: gsl-ref.info,  Node: Error handling in GSL,  Next: Mathematical Functions,  Prev: Using the library,  Up: Top
  406.  
  407. Error handling in GSL
  408. *********************
  409.  
  410.    This chapter describes the way that GSL functions report and handle
  411. errors.  By examining the status information returned by every GSL
  412. function you can determine whether it succeeded or failed, and if it
  413. failed you can find out what the precise cause of failure was.  You can
  414. also define your own error handling functions to modify the default
  415. behavior of the library.
  416.  
  417. * Menu:
  418.  
  419. * Error reporting::
  420. * Error handlers::
  421. * Using GSL error reporting in your own functions::
  422.  
  423. 
  424. File: gsl-ref.info,  Node: Error reporting,  Next: Error handlers,  Up: Error handling in GSL
  425.  
  426. Error reporting
  427. ===============
  428.  
  429.    GSL follows the thread-safe error reporting conventions of the POSIX
  430. Threads library.  Functions in GSL return a non-zero error code to
  431. indicate an error and `0' to indicate success.
  432.  
  433.      int status = gsl_function(...)
  434.      
  435.      if (status) { /* an error occurred */
  436.        .....       /* the value of status specifies the type of error */
  437.      }
  438.  
  439.    GSL routines report an error whenever they cannot perform the task
  440. requested of them.  For example, a root-finding function would return a
  441. non-zero error code if could not converge to the requested accuracy, or
  442. exceeded a limit on the number of iterations.  Situations like this are
  443. a normal occurrence when using any mathematical library and you should
  444. check the return status of the GSL functions that you call.
  445.  
  446.    Whenever a GSL routine reports an error the return value specifies
  447. the type of error.  The return value is analogous to the value of the
  448. variable `errno' in the C library.  However, the C library's `errno' is
  449. a global variable, which is not thread-safe (There can be only one
  450. instance of a global variable per program.  Different threads of
  451. execution may overwrite `errno' simultaneously).  Returning the error
  452. number directly avoids this problem.  The caller can examine the return
  453. code and decide what action to take, including ignoring the error if it
  454. is not considered serious.
  455.  
  456.    The error code numbers are defined in the file `gsl_errno.h'.  They
  457. all have the prefix `GSL_' and expand to non-zero constant integer
  458. values.  Many of the error codes use the same base name as a
  459. corresponding error code in C library.  Here are some of the most common
  460. error codes,
  461.  
  462.  - Macro: int GSL_EDOM
  463.      Domain error; used by mathematical functions when an argument
  464.      value does not fall into the domain over which the function is
  465.      defined (like EDOM in the C library)
  466.  
  467.  - Macro: int GSL_ERANGE
  468.      Range error; used by mathematical functions when the result value
  469.      is not representable because of overflow or underflow (like ERANGE
  470.      in the C library)
  471.  
  472.  - Macro: int GSL_ENOMEM
  473.      No memory available.  The system cannot allocate more virtual
  474.      memory because its capacity is full (like ENOMEM in the C
  475.      library).  This error is reported when a GSL routine encounters
  476.      problems when trying to allocate memory with `malloc'.
  477.  
  478.  - Macro: int GSL_EINVAL
  479.      Invalid argument.  This is used to indicate various kinds of
  480.      problems with passing the wrong argument to a library function
  481.      (like EINVAL in the C library).
  482.  
  483. Here is an example of some code which checks the return value of a
  484. function where an error might be reported,
  485.  
  486.      int status = gsl_fft_complex_radix2_forward (data, length);
  487.      
  488.      if (status) {
  489.          if (status == GSL_EINVAL) {
  490.             fprintf (stderr, "invalid argument, length=%d\n", length);
  491.          } else {
  492.             fprintf (stderr, "failed, gsl_errno=%d\n", status);
  493.          }
  494.          exit (-1);
  495.      }
  496.  
  497. The function `gsl_fft_complex_radix2' only accepts integer lengths
  498. which are a power of two.  If the variable `length' is not a power of
  499. two then the call to the library function will return `GSL_EINVAL',
  500. indicating that the length argument is invalid.  The `else' clause
  501. catches any other possible errors.
  502.  
  503. 
  504. File: gsl-ref.info,  Node: Error handlers,  Next: Using GSL error reporting in your own functions,  Prev: Error reporting,  Up: Error handling in GSL
  505.  
  506. Error handlers
  507. ==============
  508.  
  509.    In addition to reporting errors the library also provides an optional
  510. error handler.  The error handler is called by library functions when
  511. they are about to report an error (for example, just before they
  512. return).  The purpose of the handler is to provide a function where a
  513. breakpoint can be set when running under the debugger.
  514.  
  515.    The default behavior of the error handler is to print a short message
  516. and call `abort()' whenever an error is reported by the library.  If a
  517. library routine reports an error then the whole program will core-dump.
  518. This is a safe default for lazy programmers who do not check the
  519. return status of library routines (we don't encourage you to write
  520. programs this way).  If you turn off the default error handler or
  521. provide your own error handler then it is your responsibility to check
  522. the return values of the GSL routines.
  523.  
  524.    All GSL error handlers have the type `gsl_error_handler_t', which is
  525. defined in `gsl_errno.h',
  526.  
  527.  - Data Type: gsl_error_handler_t
  528.      This is the type of GSL error handler functions.  An error handler
  529.      will be passed three arguments, specifying the reason for the
  530.      error, the source file in which it occurred, and the line number
  531.      in that file.  The source file and line number are set at compile
  532.      time using the `__FILE__' and `__LINE__' directives in the
  533.      preprocessor.  An error handler function returns type `void'.
  534.      Error handler functions should be defined like this,
  535.  
  536.           void HANDLER (const char * reason, const char * file, int line)
  537.  
  538. To request the use of your own error handler you need to call the
  539. function `gsl_set_error_handler' which is also declared in
  540. `gsl_errno.h',
  541.  
  542.  - Function: gsl_error_handler_t gsl_set_error_handler
  543.           (gsl_error_handler_t NEW_HANDLER)
  544.      This functions sets a new error handler, NEW_HANDLER, for the GSL
  545.      library routines.  The previous handler is returned (so that you
  546.      can restore it later).  Note that the pointer to a user defined
  547.      error handler function is stored in a static variable, so there
  548.      can only be one error handler per program.
  549.  
  550.           old_handler = gsl_set_error_handler (&my_error_handler);
  551.           
  552.           .....     /* code uses new handler */
  553.           
  554.           gsl_set_error_handler (old_handler) ; /* restore old handler */
  555.  
  556.      To use the default behavior (`abort' on error) set the error
  557.      handler to `NULL',
  558.  
  559.           old_handler = gsl_set_error_handler (NULL);
  560.  
  561. Here is a skeleton outline of a program which defines its own error
  562. handler.  Imagine that the program does interactive data analysis -
  563. there is a main loop which reads commands from the user and calls
  564. library routines with user-supplied arguments,
  565.  
  566.      #include <setjmp.h>
  567.      #include <gsl/gsl_errno.h>
  568.      
  569.      jmp_buf main_loop;
  570.      void my_error_handler (const char *reason, const char *file, int line);
  571.      
  572.      main ()
  573.      {
  574.         gsl_set_error_handler (&my_error_handler);
  575.      
  576.         while (1)
  577.           {
  578.             .... /* read command from user */
  579.      
  580.             if (setjmp (main_loop) == 0)
  581.               {
  582.                  .... /* call GSL routines requested by user */
  583.               }
  584.             else
  585.               {
  586.                  .... /* my_error_handler bailed out, GSL gave an error */
  587.               }
  588.           }
  589.      }
  590.      
  591.      void
  592.      my_error_handler (const char *reason, const char *file, int line)
  593.      {
  594.          fprintf (stderr, "GSL error: %s\n", reason);
  595.          longjmp (main_loop);
  596.      }
  597.  
  598. Before entering the interactive loop the program uses
  599. `gsl_set_error_handler' to provide its own error handler
  600. `my_error_handler' for GSL error reports.  After this point the
  601. function `my_error_handler' will be invoked whenever an error is
  602. reported by GSL. The new error handler prints the cause of the error
  603. (the string `reason') and then does a non-local jump back to the main
  604. loop.  This would allow the user to fix the command which caused the
  605. error and try again.
  606.  
  607. 
  608. File: gsl-ref.info,  Node: Using GSL error reporting in your own functions,  Prev: Error handlers,  Up: Error handling in GSL
  609.  
  610. Using GSL error reporting in your own functions
  611. ===============================================
  612.  
  613.    If you are writing numerical functions in a program which also uses
  614. GSL code you may find it convenient to adopt the same error reporting
  615. conventions as in the library.
  616.  
  617.    To report an error you need to call the function `gsl_error' with a
  618. string describing the error and then return an appropriate error code
  619. from `gsl_errno.h', or a special value, such as `NaN'.  For convenience
  620. `gsl_errno.h' defines two macros to carry out these steps:
  621.  
  622.  - Macro: GSL_ERROR (REASON, GSL_ERRNO)
  623.      This macro reports an error using the GSL conventions and returns a
  624.      status value of `gsl_errno'.  It expands to the following code
  625.      fragment,
  626.  
  627.           gsl_error (reason, __FILE__, __LINE__, gsl_errno) ;
  628.           return gsl_errno ;
  629.  
  630.      The macro definition in `gsl_errno.h' actually wraps the code in a
  631.      `do { ... } while (0)' block to prevent possible parsing problems.
  632.  
  633.    Here is an example of how the macro could be used to report that a
  634. routine did not achieve a requested tolerance.  To report the error the
  635. routine needs to return the error code `GSL_ETOL'.
  636.  
  637.      if (residual > tolerance)
  638.        {
  639.          GSL_ERROR("residual exceeds specified tolerance", GSL_ETOL) ;
  640.        }
  641.  
  642.  - Macro: GSL_ERROR_RETURN (REASON, GSL_ERRNO, VALUE)
  643.      This macro is the same as `GSL_ERROR' but returns a user-defined
  644.      status value of VALUE instead of an error code.  It can be used for
  645.      mathematical functions that return a floating point value.
  646.  
  647.    Here is an example where a function needs to return a `NaN' because
  648. of a mathematical singularity,
  649.  
  650.      if (x == 0)
  651.        {
  652.          GSL_ERROR_RETURN("argument lies on singularity", GSL_ERANGE, NAN) ;
  653.        }
  654.  
  655. 
  656. File: gsl-ref.info,  Node: Mathematical Functions,  Next: Complex Numbers,  Prev: Error handling in GSL,  Up: Top
  657.  
  658. Mathematical Functions
  659. **********************
  660.  
  661.    This chapter describes basic mathematical functions.  Some of these
  662. functions are present in system libraries, but the alternative versions
  663. in the library can be used as a substitute when the system functions are
  664. not available.
  665.  
  666.    The functions and macros are defined in the header file `gsl_math.h'.
  667.  
  668. * Menu:
  669.  
  670. * Mathematical Constants::
  671. * Elementary Functions::
  672. * Testing the Sign of Numbers::
  673. * Testing for Odd and Even Numbers::
  674. * Maximum and Minimum functions::
  675.  
  676. 
  677. File: gsl-ref.info,  Node: Mathematical Constants,  Next: Elementary Functions,  Up: Mathematical Functions
  678.  
  679. Mathematical Constants
  680. ======================
  681.  
  682.    The library ensures that the standard BSD mathematical constants are
  683. defined. For reference here is a list of the constants.
  684.  
  685. `M_E'
  686.      The base of exponentials, e
  687.  
  688. `M_LOG2E'
  689.      The base-2 logarithm of e, \log_2 (e)
  690.  
  691. `M_LOG10E'
  692.      The base-10 logarithm of e, \log_10 (e)
  693.  
  694. `M_SQRT2'
  695.      The square root of two, \sqrt 2
  696.  
  697. `M_SQRT1_2'
  698.      The square root of one-half, \sqrt{1/2}
  699.  
  700. `M_SQRT3'
  701.      The square root of three, \sqrt 3
  702.  
  703. `M_PI'
  704.      The constant pi, \pi
  705.  
  706. `M_PI_2'
  707.      pi divided by two, \pi/2
  708.  
  709. `M_PI_4'
  710.      pi divided by four, \pi/4
  711.  
  712. `M_SQRTPI'
  713.      The square root of pi, \sqrt\pi
  714.  
  715. `M_2_SQRTPI'
  716.      Two divided by the square root of pi, 2/\sqrt\pi
  717.  
  718. `M_1_PI'
  719.      The reciprocal of pi, 1/\pi
  720.  
  721. `M_2_PI'
  722.      Twice the reciprocal of pi, 2/\pi
  723.  
  724. `M_LN10'
  725.      The natural logarithm of ten, \ln(10)
  726.  
  727. `M_LN2'
  728.      The natural logarith of two, \ln(2)
  729.  
  730. `M_LNPI'
  731.      The natural logarithm of pi, \ln(\pi)
  732.  
  733. `M_EULER'
  734.      Euler's constant, \gamma
  735.  
  736. 
  737. File: gsl-ref.info,  Node: Elementary Functions,  Next: Testing the Sign of Numbers,  Prev: Mathematical Constants,  Up: Mathematical Functions
  738.  
  739. Elementary Functions
  740. ====================
  741.  
  742.  - Function: double gsl_log1p (const double X)
  743.      This function computes the value of \log(1+x) in a way that is
  744.      accurate for small X. It provides an alternative to the system
  745.      function `log1p(x)'.
  746.  
  747.  - Function: double gsl_hypot (const double X, const double Y)
  748.      This function computes the value of \sqrt{x^2 + y^2} in a way that
  749.      avoid overflow. It provides an alternative to the system function
  750.      `hypot(x,y)'.
  751.  
  752. 
  753. File: gsl-ref.info,  Node: Testing the Sign of Numbers,  Next: Testing for Odd and Even Numbers,  Prev: Elementary Functions,  Up: Mathematical Functions
  754.  
  755. Testing the Sign of Numbers
  756. ===========================
  757.  
  758.  - Macro: GSL_SIGN (x)
  759.      This macro returns the sign of X. It is defined as `((x) >= 0 ? 1
  760.      : -1)'. Note that with this definition the sign of zero is positive
  761.      (regardless of its IEEE sign bit).
  762.  
  763. 
  764. File: gsl-ref.info,  Node: Testing for Odd and Even Numbers,  Next: Maximum and Minimum functions,  Prev: Testing the Sign of Numbers,  Up: Mathematical Functions
  765.  
  766. Testing for Odd and Even Numbers
  767. ================================
  768.  
  769.  - Macro: GSL_IS_ODD (n)
  770.      This macro evaluates to 1 if N is odd and 0 if N is even. The
  771.      argument N must be of integer type.
  772.  
  773.  - Macro: GSL_IS_EVEN (n)
  774.      This macro is the opposite of `GSL_IS_ODD(n)'. It evaluates to 1 if
  775.      N is even and 0 if N is odd. The argument N must be of integer
  776.      type.
  777.  
  778. 
  779. File: gsl-ref.info,  Node: Maximum and Minimum functions,  Prev: Testing for Odd and Even Numbers,  Up: Mathematical Functions
  780.  
  781. Maximum and Minimum functions
  782. =============================
  783.  
  784.  - Macro: GSL_MAX (a, b)
  785.      This macro returns the maximum of A and B. It is defined as `((a)
  786.      > (b) ? (a):(b))'.
  787.  
  788.  - Macro: GSL_MIN (a, b)
  789.      This macro returns the minimum of A and B. It is defined as `((a)
  790.      < (b) ? (a):(b))'.
  791.  
  792.  - Function: extern inline double GSL_MAX_DBL (double A, double B)
  793.      This function returns the maximum of the double precision numbers
  794.      A and B using an inline function. The use of a function allows for
  795.      type checking of the arguments as an extra safety feature. On
  796.      platforms where inline functions are not available the macro
  797.      `GSL_MAX' will be automatically substituted.
  798.  
  799.  - Function: extern inline double GSL_MIN_DBL (double A, double B)
  800.      This function returns the minimum of the double precision numbers
  801.      A and B using an inline function. The use of a function allows for
  802.      type checking of the arguments as an extra safety feature. On
  803.      platforms where inline functions are not available the macro
  804.      `GSL_MIN' will be automatically substituted.
  805.  
  806.  - Function: extern inline int GSL_MAX_INT (int A, int B)
  807.  - Function: extern inline int GSL_MIN_INT (int A, int B)
  808.      These functions return the maximum or minimum of the integers A
  809.      and B using an inline function.  On platforms where inline
  810.      functions are not available the macros `GSL_MAX' or `GSL_MIN' will
  811.      be automatically substituted.
  812.  
  813.  - Function: extern inline long double GSL_MAX_LDBL (long double A,
  814.           long double B)
  815.  - Function: extern inline long double GSL_MIN_LDBL (long double A,
  816.           long double B)
  817.      These functions return the maximum or minimum of the long doubles A
  818.      and B using an inline function.  On platforms where inline
  819.      functions are not available the macros `GSL_MAX' or `GSL_MIN' will
  820.      be automatically substituted.
  821.  
  822. 
  823. File: gsl-ref.info,  Node: Complex Numbers,  Next: Vectors and Matrices,  Prev: Mathematical Functions,  Up: Top
  824.  
  825. Complex Numbers
  826. ***************
  827.  
  828.    The functions described in this chapter provide support for complex
  829. numbers.  The algorithms take care to avoid unnecessary intermediate
  830. underflows and overflows, allowing the functions to evaluated over the
  831. as much of the complex plane as possible. (FIXME: this still needs to be
  832. done for the csc,sec,cot,csch,sech,coth functions).
  833.  
  834.    For multiple-valued functions the branch cuts have been chosen to
  835. follow the conventions of Abramowitz and Stegun in the `Handbook of
  836. Mathematical Functions'. The functions return principal values which are
  837. the same as those is GNU Calc, which in turn are the same as those in
  838. `Common Lisp, The Language (Second Edition)' (1) and the HP-28/48
  839. series of calculators.
  840.  
  841. * Menu:
  842.  
  843. * Complex numbers::
  844. * Properties of complex numbers::
  845. * Complex arithmetic operators::
  846. * Elementary Complex Functions::
  847. * Complex Trigonometric Functions::
  848. * Inverse Complex Trigonometric Functions::
  849. * Complex Hyperbolic Functions::
  850. * Inverse Complex Hyperbolic Functions::
  851. * Complex Number References and Further Reading::
  852.  
  853.    ---------- Footnotes ----------
  854.  
  855.    (1) The first edition of `Common Lisp, The Language' used different
  856. definitions from the second edition.
  857.  
  858. 
  859. File: gsl-ref.info,  Node: Complex numbers,  Next: Properties of complex numbers,  Up: Complex Numbers
  860.  
  861. Complex numbers
  862. ===============
  863.  
  864.    Complex numbers are represented using the type `gsl_complex'. The
  865. internal representation of this type may vary across platforms and
  866. should not be accessed directly. The functions and macros described
  867. below allow complex numbers to be manipulated in a portable way
  868.  
  869.    For reference, the default form of the `gsl_complex' type is given
  870. by the following struct,
  871.  
  872.      typedef struct
  873.      {
  874.        double dat[2];
  875.      } gsl_complex ;
  876.  
  877. The real and imaginary part are stored in contiguous elements of a two
  878. element array. This eliminates any padding between the real and
  879. imaginary parts, `dat[0]' and `dat[1]', allowing the struct to be
  880. mapped correctly onto packed complex arrays.
  881.  
  882.  - Function: gsl_complex gsl_complex_xy (double X, double Y)
  883.      This function uses the cartesian components (X,Y) to return the
  884.      complex number z = x + i y.
  885.  
  886.  - Function: gsl_complex gsl_complex_polar (double R, double THETA)
  887.      This function returns the complex number z = r \exp(i \theta) = r
  888.      (\cos(\theta) + i \sin(\theta)) from the polar representation
  889.      (R,THETA).
  890.  
  891.  - Macro: GSL_REAL (Z)
  892.  - Macro: GSL_IMAG (Z)
  893.      These macros return the real and imaginary parts of the complex
  894.      number Z.
  895.  
  896.  - Macro: GSL_SET_COMPLEX (ZP, X, Y)
  897.      This macro uses the cartesian components (X,Y) to set the real and
  898.      imaginary parts of the complex number pointed to by ZP.  For
  899.      example,
  900.  
  901.           GSL_SET_COMPLEX(&z, 3, 4)
  902.  
  903.      sets Z to be 3 + 4i.
  904.  
  905.  - Macro: GSL_SET_REAL (ZP,X)
  906.  - Macro: GSL_SET_IMAG (ZP,Y)
  907.      These macros allow the real and imaginary parts of the complex
  908.      number pointed to by ZP to be set independently.
  909.  
  910. 
  911. File: gsl-ref.info,  Node: Properties of complex numbers,  Next: Complex arithmetic operators,  Prev: Complex numbers,  Up: Complex Numbers
  912.  
  913. Properties of complex numbers
  914. =============================
  915.  
  916.  - Function: double gsl_complex_arg (gsl_complex Z)
  917.      This function returns the argument of the complex number Z,
  918.      \arg(z), where -\pi < \arg(z) <= \pi.
  919.  
  920.  - Function: double gsl_complex_abs (gsl_complex Z)
  921.      This function returns the magnitude of the complex number Z, |z|.
  922.  
  923.  - Function: double gsl_complex_abs2 (gsl_complex Z)
  924.      This function returns the squared magnitued of the complex number
  925.      Z, |z|^2.
  926.  
  927.  - Function: double gsl_complex_logabs (gsl_complex Z)
  928.      This function returns the natural logarithm of the magnitude of the
  929.      complex number Z, \log|z|.  It allows an accurate evaluation of
  930.      \log|z| when |z| is close to one. The direct evaluation of
  931.      `log(gsl_complex_abs(z))' would lead to a loss of precision in
  932.      this case.
  933.  
  934. 
  935. File: gsl-ref.info,  Node: Complex arithmetic operators,  Next: Elementary Complex Functions,  Prev: Properties of complex numbers,  Up: Complex Numbers
  936.  
  937. Complex arithmetic operators
  938. ============================
  939.  
  940.  - Function: gsl_complex gsl_complex_add (gsl_complex A, gsl_complex B)
  941.      This function returns the sum of the complex numbers A and B,
  942.      z=a+b.
  943.  
  944.  - Function: gsl_complex gsl_complex_sub (gsl_complex A, gsl_complex B)
  945.      This function returns the difference of the complex numbers A and
  946.      B, z=a-b.
  947.  
  948.  - Function: gsl_complex gsl_complex_mul (gsl_complex A, gsl_complex B)
  949.      This functions returns the product of the complex numbers A and B,
  950.      z=ab.
  951.  
  952.  - Function: gsl_complex gsl_complex_div (gsl_complex A, gsl_complex B)
  953.      This functions returns the quotient of the complex numbers A and
  954.      B, z=a/b.
  955.  
  956.  - Function: gsl_complex gsl_complex_add_real (gsl_complex A, double X)
  957.      This functions returns the sum of the complex number A and the
  958.      real number X, z=a+x.
  959.  
  960.  - Function: gsl_complex gsl_complex_sub_real (gsl_complex A, double X)
  961.      This functions returns the difference of the complex number A and
  962.      the real number X, z=a-x.
  963.  
  964.  - Function: gsl_complex gsl_complex_mul_real (gsl_complex A, double B)
  965.      This functions returns the product of the complex number A and the
  966.      real number X, z=ax.
  967.  
  968.  - Function: gsl_complex gsl_complex_div_real (gsl_complex A, double B)
  969.      This functions returns the quotient of the complex number A and the
  970.      real number X, z=a/x.
  971.  
  972.  - Function: gsl_complex gsl_complex_add_imag (gsl_complex A, double Y)
  973.      This function returns the sum of the complex number A and the
  974.      imaginary number iY, z=a+iy.
  975.  
  976.  - Function: gsl_complex gsl_complex_sub_imag (gsl_complex A, double Y)
  977.      This function returns the difference of the complex number A and
  978.      the imaginary number iY, z=a-iy.
  979.  
  980.  - Function: gsl_complex gsl_complex_mul_imag (gsl_complex A, double Y)
  981.      This function returns the product of the complex number A and the
  982.      imaginary number iY, z=a*(iy).
  983.  
  984.  - Function: gsl_complex gsl_complex_div_imag (gsl_complex A, double Y)
  985.      This function returns the quotient of the complex number A and the
  986.      imaginary number iY, z=a/(iy).
  987.  
  988.  - Function: gsl_complex gsl_complex_conjugate (gsl_complex Z)
  989.      This function returns the complex conjugate of the complex number
  990.      Z, z^* = x - i y.
  991.  
  992.  - Function: gsl_complex gsl_complex_inverse (gsl_complex Z)
  993.      This function returns the inverse, or reciprocal, of the complex
  994.      number Z, 1/z = (x - i y)/(x^2 + y^2).
  995.  
  996.  - Function: gsl_complex gsl_complex_negative (gsl_complex Z)
  997.      This function returns the negative of the complex number Z, -z =
  998.      (-x) + i(-y).
  999.  
  1000. 
  1001. File: gsl-ref.info,  Node: Elementary Complex Functions,  Next: Complex Trigonometric Functions,  Prev: Complex arithmetic operators,  Up: Complex Numbers
  1002.  
  1003. Elementary Complex Functions
  1004. ============================
  1005.  
  1006.  - Function: gsl_complex gsl_complex_sqrt (gsl_complex Z)
  1007.      This function returns the square root of the complex number Z,
  1008.      \sqrt z. The branch cut is the negative real axis. The result
  1009.      always lies in the right half of the complex plane.
  1010.  
  1011.  - Function: gsl_complex gsl_complex_sqrt_real (double x)
  1012.      This function returns the complex square root of the real number
  1013.      X, where X may be negative.
  1014.  
  1015.  - Function: gsl_complex gsl_complex_pow (gsl_complex Z, gsl_complex A)
  1016.      The function returns the complex number Z raised to the complex
  1017.      power A, z^a. This is computed as \exp(\log(z)*a) using complex
  1018.      logarithms and complex exponentials.
  1019.  
  1020.  - Function: gsl_complex gsl_complex_pow_real (gsl_complex Z, double A)
  1021.      This function returns the complex number Z raised to the real
  1022.      power B, z^b.
  1023.  
  1024.  - Function: gsl_complex gsl_complex_exp (gsl_complex Z)
  1025.      This function returns the complex exponential of the complex number
  1026.      Z, \exp(z).
  1027.  
  1028.  - Function: gsl_complex gsl_complex_log (gsl_complex Z)
  1029.      This function returns the complex natural logarithm (base e) of
  1030.      the complex number Z, \log(z).  The branch cut is the negative
  1031.      real axis.
  1032.  
  1033.  - Function: gsl_complex gsl_complex_log10 (gsl_complex Z)
  1034.      This function returns the complex base-10 logarithm of the complex
  1035.      number Z, \log_10 (z).
  1036.  
  1037.  - Function: gsl_complex gsl_complex_log_b (gsl_complex Z, gsl_complex
  1038.           B)
  1039.      This function returns the complex base-B logarithm of the complex
  1040.      number Z, \log_b(z). This quantity is computed as the ratio
  1041.      \log(z)/\log(b).
  1042.  
  1043. 
  1044. File: gsl-ref.info,  Node: Complex Trigonometric Functions,  Next: Inverse Complex Trigonometric Functions,  Prev: Elementary Complex Functions,  Up: Complex Numbers
  1045.  
  1046. Complex Trigonometric Functions
  1047. ===============================
  1048.  
  1049.  - Function: gsl_complex gsl_complex_sin (gsl_complex Z)
  1050.      This function returns the complex sine of the complex number Z,
  1051.      \sin(z) = (\exp(iz) - \exp(-iz))/(2i).
  1052.  
  1053.  - Function: gsl_complex gsl_complex_cos (gsl_complex Z)
  1054.      This function returns the complex cosine of the complex number Z,
  1055.      \cos(z) = (\exp(iz) + \exp(-iz))/2.
  1056.  
  1057.  - Function: gsl_complex gsl_complex_tan (gsl_complex Z)
  1058.      This function returns the complex tangent of the complex number Z,
  1059.      \tan(z) = \sin(z)/\cos(z).
  1060.  
  1061.  - Function: gsl_complex gsl_complex_sec (gsl_complex Z)
  1062.      This function returns the complex secant of the complex number Z,
  1063.      \sec(z) = 1/\cos(z).
  1064.  
  1065.  - Function: gsl_complex gsl_complex_csc (gsl_complex Z)
  1066.      This function returns the complex cosecant of the complex number Z,
  1067.      \csc(z) = 1/\sin(z).
  1068.  
  1069.  - Function: gsl_complex gsl_complex_cot (gsl_complex Z)
  1070.      This function returns the complex cotangent of the complex number
  1071.      Z, \cot(z) = 1/\tan(z).
  1072.  
  1073. 
  1074. File: gsl-ref.info,  Node: Inverse Complex Trigonometric Functions,  Next: Complex Hyperbolic Functions,  Prev: Complex Trigonometric Functions,  Up: Complex Numbers
  1075.  
  1076. Inverse Complex Trigonometric Functions
  1077. =======================================
  1078.  
  1079.  - Function: gsl_complex gsl_complex_arcsin (gsl_complex Z)
  1080.      This function returns the complex arcsine of the complex number Z,
  1081.      \arcsin(z). The branch cuts are on the real axis, less than -1 and
  1082.      greater than 1.
  1083.  
  1084.  - Function: gsl_complex gsl_complex_arcsin_real (double Z)
  1085.      This function returns the complex arcsine of the real number Z,
  1086.      \arcsin(z). For z between -1 and 1, the function returns a real
  1087.      value in the range (-\pi,\pi]. For z less than -1 the result has a
  1088.      real part of -\pi/2 and a positive imaginary part.  For z greater
  1089.      than 1 the result has a real part of \pi/2 and a negative
  1090.      imaginary part.
  1091.  
  1092.  - Function: gsl_complex gsl_complex_arccos (gsl_complex Z)
  1093.      This function returns the complex arccosine of the complex number
  1094.      Z, \arccos(z). The branch cuts are on the real axis, less than -1
  1095.      and greater than 1.
  1096.  
  1097.  - Function: gsl_complex gsl_complex_arccos_real (double Z)
  1098.      This function returns the complex arccosine of the real number Z,
  1099.      \arccos(z). For z between -1 and 1, the function returns a real
  1100.      value in the range [0,\pi]. For z less than -1 the result has a
  1101.      real part of \pi/2 and a negative imaginary part.  For z greater
  1102.      than 1 the result is purely imaginary and positive.
  1103.  
  1104.  - Function: gsl_complex gsl_complex_arctan (gsl_complex Z)
  1105.      This function returns the complex arctangent of the complex number
  1106.      Z, \arctan(z). The branch cuts are on the imaginary axis, below -i
  1107.      and above i.
  1108.  
  1109.  - Function: gsl_complex gsl_complex_arcsec (gsl_complex Z)
  1110.      This function returns the complex arcsecant of the complex number
  1111.      Z, \arcsec(z) = \arccos(1/z).
  1112.  
  1113.  - Function: gsl_complex gsl_complex_arcsec_real (double Z)
  1114.      This function returns the complex arcsecant of the real number Z,
  1115.      \arcsec(z) = \arccos(1/z).
  1116.  
  1117.  - Function: gsl_complex gsl_complex_arccsc (gsl_complex Z)
  1118.      This function returns the complex arccosecant of the complex
  1119.      number Z, \arccsc(z) = \arcsin(1/z).
  1120.  
  1121.  - Function: gsl_complex gsl_complex_arccsc_real (double Z)
  1122.      This function returns the complex arccosecant of the real number Z,
  1123.      \arccsc(z) = \arcsin(1/z).
  1124.  
  1125.  - Function: gsl_complex gsl_complex_arccot (gsl_complex Z)
  1126.      This function returns the complex arccotangent of the complex
  1127.      number Z, \arccot(z) = \arctan(1/z).
  1128.  
  1129. 
  1130. File: gsl-ref.info,  Node: Complex Hyperbolic Functions,  Next: Inverse Complex Hyperbolic Functions,  Prev: Inverse Complex Trigonometric Functions,  Up: Complex Numbers
  1131.  
  1132. Complex Hyperbolic Functions
  1133. ============================
  1134.  
  1135.  - Function: gsl_complex gsl_complex_sinh (gsl_complex Z)
  1136.      This function returns the complex hyperbolic sine of the complex
  1137.      number Z, \sinh(z) = (\exp(z) - \exp(-z))/2.
  1138.  
  1139.  - Function: gsl_complex gsl_complex_cosh (gsl_complex Z)
  1140.      This function returns the complex hyperbolic cosine of the complex
  1141.      number Z, \cosh(z) = (\exp(z) + \exp(-z))/2.
  1142.  
  1143.  - Function: gsl_complex gsl_complex_tanh (gsl_complex Z)
  1144.      This function returns the complex hyperbolic tangent of the
  1145.      complex number Z, \tanh(z) = \sinh(z)/\cosh(z).
  1146.  
  1147.  - Function: gsl_complex gsl_complex_sech (gsl_complex Z)
  1148.      This function returns the complex hyperbolic secant of the complex
  1149.      number Z, \sech(z) = 1/\cosh(z).
  1150.  
  1151.  - Function: gsl_complex gsl_complex_csch (gsl_complex Z)
  1152.      This function returns the complex hyperbolic cosecant of the
  1153.      complex number Z, \csch(z) = 1/\sinh(z).
  1154.  
  1155.  - Function: gsl_complex gsl_complex_coth (gsl_complex Z)
  1156.      This function returns the complex hyperbolic cotangent of the
  1157.      complex number Z, \coth(z) = 1/\tanh(z).
  1158.  
  1159. 
  1160. File: gsl-ref.info,  Node: Inverse Complex Hyperbolic Functions,  Next: Complex Number References and Further Reading,  Prev: Complex Hyperbolic Functions,  Up: Complex Numbers
  1161.  
  1162. Inverse Complex Hyperbolic Functions
  1163. ====================================
  1164.  
  1165.  - Function: gsl_complex gsl_complex_arcsinh (gsl_complex Z)
  1166.      This function returns the complex hyperbolic arcsine of the
  1167.      complex number Z, \arcsinh(z).  The branch cuts are on the
  1168.      imaginary axis, below -i and above i.
  1169.  
  1170.  - Function: gsl_complex gsl_complex_arccosh (gsl_complex Z)
  1171.      This function returns the complex hyperbolic arccosine of the
  1172.      complex number Z, \arccosh(z).  The branch cut is on the real less
  1173.      than 1.
  1174.  
  1175.  - Function: gsl_complex gsl_complex_arccosh_real (double Z)
  1176.      This function returns the complex hyperbolic arccosine of the real
  1177.      number Z, \arccosh(z).
  1178.  
  1179.  - Function: gsl_complex gsl_complex_arctanh (gsl_complex Z)
  1180.      This function returns the complex hyperbolic arctangent of the
  1181.      complex number Z, \arctanh(z).  The branch cuts are on the real
  1182.      axis, less than -1 and greater than 1.
  1183.  
  1184.  - Function: gsl_complex gsl_complex_arctanh_real (double Z)
  1185.      This function returns the complex hyperbolic arctangent of the real
  1186.      number Z, \arctanh(z).
  1187.  
  1188.  - Function: gsl_complex gsl_complex_arcsech (gsl_complex Z)
  1189.      This function returns the complex hyperbolic arcsecant of the
  1190.      complex number Z, \arcsech(z) = \arccosh(1/z).
  1191.  
  1192.  - Function: gsl_complex gsl_complex_arccsch (gsl_complex Z)
  1193.      This function returns the complex hyperbolic arccosecant of the
  1194.      complex number Z, \arccsch(z) = \arcsin(1/z).
  1195.  
  1196.  - Function: gsl_complex gsl_complex_arccoth (gsl_complex Z)
  1197.      This function returns the complex hyperbolic arccotangent of the
  1198.      complex number Z, \arccoth(z) = \arctanh(1/z).
  1199.  
  1200. 
  1201. File: gsl-ref.info,  Node: Complex Number References and Further Reading,  Prev: Inverse Complex Hyperbolic Functions,  Up: Complex Numbers
  1202.  
  1203. References and Further Reading
  1204. ==============================
  1205.  
  1206.    The implementations of the elementary and trigonometric functions are
  1207. based on the following papers,
  1208.  
  1209.      T. E. Hull and Thomas F. Fairgrieve and Ping Tak Peter Tang,
  1210.      "Implementing Complex Elementary Functions Using Exception
  1211.      Handling", `ACM Transactions on Mathematical Software', Volume 20
  1212.      (1994), pp 215-244, Corrigenda, p553
  1213.  
  1214.      T. E. Hull and Thomas F. Fairgrieve and Ping Tak Peter Tang,
  1215.      "Implementing the complex arcsin and arccosine functions using
  1216.      exception handling", `ACM Transactions on Mathematical Software',
  1217.      Volume 23 (1997) pp 299-335
  1218.  
  1219. The general formulas and details of branch cuts can be found in the
  1220. following books,
  1221.  
  1222.      Abramowitz and Stegun, `Handbook of Mathematical Functions',
  1223.      "Circular Functions in Terms of Real and Imaginary Parts", Formulas
  1224.      4.3.55-58, "Inverse Circular Functions in Terms of Real and
  1225.      Imaginary Parts", Formulas 4.4.37-39, "Hyperbolic Functions in
  1226.      Terms of Real and Imaginary Parts", Formulas 4.5.49-52, "Inverse
  1227.      Hyperbolic Functions - relation to Inverse Circular Functions",
  1228.      Formulas 4.6.14-19.
  1229.  
  1230.      Dave Gillespie, `Calc Manual', Free Software Foundation, ISBN
  1231.      1-882114-18-3
  1232.  
  1233. 
  1234. File: gsl-ref.info,  Node: Vectors and Matrices,  Next: BLAS Support,  Prev: Complex Numbers,  Up: Top
  1235.  
  1236. Vectors and Matrices
  1237. ********************
  1238.  
  1239.    The functions described in this chapter provide a simple vector and
  1240. matrix interface to ordinary C arrays. The memory management of these
  1241. arrays is implemented using a single underlying type, known as a block.
  1242. By writing your functions in terms of vectors and matrices you can pass
  1243. a single structure containing both data and dimensions without needing
  1244. additional function arguments.  The structures are compatible with the
  1245. vector and matrix formats used by BLAS routines.
  1246.  
  1247. * Menu:
  1248.  
  1249. * Data types::
  1250. * The block struct::
  1251. * Block allocation::
  1252. * Reading and writing blocks::
  1253. * Example programs for blocks::
  1254. * The vector struct::
  1255. * Vector allocation::
  1256. * Accessing vector elements::
  1257. * Initializing vector elements::
  1258. * Reading and writing vectors::
  1259. * Creating subvector views::
  1260. * Copying vectors::
  1261. * Exchanging elements::
  1262. * Vector operations::
  1263. * Finding maximum and minimum elements of vectors::
  1264. * Vector properties::
  1265. * Example programs for vectors::
  1266. * The matrix struct::
  1267. * Matrix allocation::
  1268. * Accessing matrix elements::
  1269. * Initializing matrix elements::
  1270. * Reading and writing matrices::
  1271. * Creating submatrix views::
  1272. * Creating row and column views::
  1273. * Copying matrices::
  1274. * Copying rows and columns::
  1275. * Exchanging rows and columns::
  1276. * Matrix operations::
  1277. * Finding maximum and minimum elements of matrices::
  1278. * Matrix properties::
  1279. * Example programs for matrices::
  1280. * Vector and Matrix References and Further Reading::
  1281.  
  1282. 
  1283. File: gsl-ref.info,  Node: Data types,  Next: The block struct,  Up: Vectors and Matrices
  1284.  
  1285. Data types
  1286. ==========
  1287.  
  1288.    All the functions are available for each of the standard data-types.
  1289. The versions for `double' have the prefix `gsl_block', `gsl_vector' and
  1290. `gsl_matrix'.  Similarly the versions for single-precision `float'
  1291. arrays have the prefix `gsl_block_float', `gsl_vector_float' and
  1292. `gsl_matrix_float'.  The full list of available types is given below,
  1293.  
  1294.      gsl_block                       double
  1295.      gsl_block_float                 float
  1296.      gsl_block_long_double           long double
  1297.      gsl_block_int                   int
  1298.      gsl_block_uint                  unsigned int
  1299.      gsl_block_long                  long
  1300.      gsl_block_ulong                 unsigned long
  1301.      gsl_block_short                 short
  1302.      gsl_block_ushort                unsigned short
  1303.      gsl_block_char                  char
  1304.      gsl_block_uchar                 unsigned char
  1305.      gsl_block_complex               complex double
  1306.      gsl_block_complex_float         complex float
  1307.      gsl_block_complex_long_double   complex long double
  1308.  
  1309. Corresponding types exist for the `gsl_vector' and `gsl_matrix'
  1310. functions.
  1311.  
  1312.